<template>
  <div>
    <div class="search-container">
      <el-button class="search-btn" type="primary" icon="el-icon-edit" @click="tableSwitch(1)">定期存款积分规则</el-button>
      <el-button class="search-btn" type="primary" icon="el-icon-edit" @click="tableSwitch(2)">业务交易积分规则</el-button>
      <el-button class="search-btn" type="primary" icon="el-icon-edit" @click="tableSwitch(3)">积分比例</el-button>
    </div>

<!--    定期存款积分规则表-->
    <el-table v-if="isDimIntFixTable" :key='dimIntFixTableKey' :data="DimIntFixlist" v-loading="listLoading" border fit highlight-current-row>
      <el-table-column align="center" prop="id" label="序号" width="140">
      </el-table-column>
      <el-table-column align="center" prop="ruleId" label="积分规则编号" width="120" show-overflow-tooltip>
      </el-table-column>
      <el-table-column align="center" prop="regularGrade" label="定期档次" width="180" show-overflow-tooltip>
      </el-table-column>
      <el-table-column align="center" prop="exIntSta" label="兑换积分标准（积分/每万元）">
      </el-table-column>
      <el-table-column align="center" prop="intExGd" label="积分兑换物品价值（元）">
      </el-table-column>
      <el-table-column align="center" prop="baseMoney" label="金额基数">
      </el-table-column>
      <el-table-column align="center" prop="status" label="状态">
      </el-table-column>
      <el-table-column align="center" prop="beginDate" label="生效时间">
      </el-table-column>
      <!--<el-table-column align="center" label="调整时间">
        <template slot-scope="scope">
          <span>{{scope.row.updateDt | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</span>
        </template>
      </el-table-column>-->
      <el-table-column align="center" label="操作" width="270" v-if="integral_update">
        <template slot-scope="scope">
          <el-button v-if="integral_update" size="mini" type="primary" @click="handleEdit(scope.row)" style="float: left">编辑</el-button>
          <el-button v-if="integral_update" size="mini" type="primary" @click="getHistory(scope.row)" style="float: left">历史记录</el-button>
          <el-button v-if="integral_update && scope.row.status =='停用'" size="mini" type="primary" @click="getUse(scope.row)" style="float: left">启用</el-button>
          <el-button v-if="integral_update && scope.row.status =='生效'" size="mini" type="primary" @click="getStop(scope.row)" style="float: left">停用</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--    定期存款积分规则表历史记录-->
    <el-dialog title="历史记录" :visible.sync="isDimIntFixTableNew" width="80%">
    <el-table  :key='dimIntFixTableKey' :data="DimIntFixlistNew" v-loading="listLoading" border fit highlight-current-row>
      <el-table-column align="center" prop="id" label="序号" width="140">
      </el-table-column>
      <el-table-column align="center" prop="ruleId" label="积分规则编号" width="120" show-overflow-tooltip>
      </el-table-column>
      <el-table-column align="center" prop="regularGrade" label="定期档次" width="180" show-overflow-tooltip>
      </el-table-column>
      <el-table-column align="center" prop="exIntSta" label="兑换积分标准（积分/每万元）">
      </el-table-column>
      <el-table-column align="center" prop="intExGd" label="积分兑换物品价值（元）">
      </el-table-column>
      <el-table-column align="center" prop="baseMoney" label="金额基数">
      </el-table-column>
      <el-table-column align="center" prop="status" label="状态">
      </el-table-column>
      <el-table-column align="center" prop="beginDate" label="生效时间">
      </el-table-column>
      <el-table-column align="center" prop="endDate" label="失效时间">
      </el-table-column>
      <el-table-column align="center" label="操作" width="180" v-if="integral_update">
        <template slot-scope="scope">
          <el-button v-if="integral_update && scope.row.status =='停用'" size="mini" type="primary" @click="getUse(scope.row)" style="float: left">重新启用</el-button>
          <el-button v-if="integral_update && scope.row.status =='生效'" size="mini" type="primary" @click="getStop(scope.row)" style="float: left">停用</el-button>
        </template>
      </el-table-column>
    </el-table>
    </el-dialog>



    <!--业务交易积分规则表-->
    <el-table v-if="isDimBusIntTranTable" :key='dimBusIntTranTableKey' :data="DimBusIntTranlist" v-loading="listLoading" border fit highlight-current-row>
      <el-table-column align="center" prop="id" label="序号" width="140">
      </el-table-column>
      <el-table-column align="center" prop="ruleId" label="积分规则编号" width="120" show-overflow-tooltip>
      </el-table-column>
      <el-table-column align="center" prop="busBigtype" label="业务大类" width="140" show-overflow-tooltip>
      </el-table-column>
      <el-table-column align="center" prop="busSmatype" label="业务小类" width="100" show-overflow-tooltip>
      </el-table-column>
      <el-table-column align="center" prop="remark" label="参数">
      </el-table-column>
      <el-table-column align="center" prop="int" label="积分值">
      </el-table-column>
      <el-table-column align="center" prop="freRate" label="频率">
<!--        <template slot-scope="scope">-->
<!--          <el-tag>-->
<!--            {{scope.row.freRate | freRateFilter}}-->
<!--          </el-tag>-->
<!--        </template>-->
      </el-table-column>
      <el-table-column align="center" prop="status" label="状态">
      </el-table-column>
      <el-table-column align="center" prop="beginDate" label="生效时间">
      </el-table-column>
      <el-table-column align="center" label="操作" width="250" v-if="integral_update">
        <template slot-scope="scope">
          <el-button v-if="integral_update" size="mini" type="primary" @click="handleEdit(scope.row)" style="float: left">编辑</el-button>
          <el-button v-if="integral_update" size="mini" type="primary" @click="getHistory(scope.row)" style="float: left">历史记录</el-button>
          <el-button v-if="integral_update && scope.row.status =='停用'" size="mini" type="primary" @click="getUseNew(scope.row)" style="float: left">启用</el-button>
          <el-button v-if="integral_update && scope.row.status =='生效'" size="mini" type="primary" @click="getStopNew(scope.row)" style="float: left">停用</el-button>
        </template>
      </el-table-column>
    </el-table>


    <!--业务交易积分规则表历史记录-->
    <el-dialog title="历史记录" :visible.sync="isDimBusIntTranTableNew" width="90%">
      <el-table v-if="isDimBusIntTranTable" :key='dimBusIntTranTableKey' :data="DimBusIntTranlistNew" v-loading="listLoading" border fit highlight-current-row>
        <el-table-column align="center" prop="id" label="序号" width="140">
        </el-table-column>
        <el-table-column align="center" prop="ruleId" label="积分规则编号" width="120" show-overflow-tooltip>
        </el-table-column>
        <el-table-column align="center" prop="busBigtype" label="业务大类" width="140" show-overflow-tooltip>
        </el-table-column>
        <el-table-column align="center" prop="busSmatype" label="业务小类" width="100" show-overflow-tooltip>
        </el-table-column>
        <el-table-column align="center" prop="remark" label="参数">
        </el-table-column>
        <el-table-column align="center" prop="int" label="积分值">
        </el-table-column>
        <el-table-column align="center" prop="freRate" label="频率">
        </el-table-column>
        <el-table-column align="center" prop="status" label="状态">
        </el-table-column>
        <el-table-column align="center" prop="beginDate" label="生效时间">
        </el-table-column>
        <el-table-column align="center" prop="endDate" label="失效时间">
        </el-table-column>
        <el-table-column align="center" label="操作" width="180" v-if="integral_update">
          <template slot-scope="scope">
            <el-button v-if="integral_update && scope.row.status =='停用'" size="mini" type="primary" @click="getUseNew(scope.row)" style="float: left">重新启用</el-button>
            <el-button v-if="integral_update && scope.row.status =='生效'" size="mini" type="primary" @click="getStopNew(scope.row)" style="float: left">停用</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>


    <!--    积分比例表-->
    <el-table v-if="isDimIntRatTable" :key='dimIntRatTableKey' :data="DimIntRatlist" v-loading="listLoading" border fit highlight-current-row>
      <el-table-column align="center" prop="int" label="积分" width="140">
      </el-table-column>
      <el-table-column align="center" prop="cash" label="现金" width="140" show-overflow-tooltip>
      </el-table-column>
      <el-table-column align="center" label="调整时间">
        <template slot-scope="scope">
          <span>{{scope.row.updateDt | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="180" v-if="integral_update">
        <template slot-scope="scope">
          <el-button v-if="integral_update" size="mini" type="primary" @click="handleEdit(scope.row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>

    <div v-show="!listLoading" class="pagination-container">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.current" :page-size="listQuery.size" :page-sizes="[10, 40, 80, 100]" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>

    <el-dialog :title="textMap[dimIntFixDialogStatus]" :visible.sync="dimIntFixDialogFormVisible" width="40%">
      <el-form label-width="120px" :model="dimIntFixFrom" :rules="dimIntFixRules" ref="dimIntFixFrom">

        <el-form-item label="积分规则编号" prop="ruleId">
          <el-input disabled class="w347" v-model="dimIntFixFrom.ruleId"></el-input>
        </el-form-item>
        <el-form-item label="定期档次" prop="regularGrade">
          <el-input disabled class="w347" v-model="dimIntFixFrom.regularGrade"></el-input>
        </el-form-item>
        <el-form-item label="兑换积分标准" prop="exIntSta">
          <el-input-number min="1" max="999" class="w347" v-model.number="dimIntFixFrom.exIntSta"></el-input-number>
        </el-form-item>
        <el-form-item label="金额基数" prop="baseMoney">
          <el-input-number mix="1" max="10000000000" class="w347" v-model.number="dimIntFixFrom.baseMoney"></el-input-number>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input max="50" class="w347" v-model.remark="dimIntFixFrom.remark"></el-input>
        </el-form-item>
        <el-form-item label="调整时间" prop="updateDt">
<!--          <el-input class="w347" v-model="dimIntFixFrom.updateDt"></el-input>-->
<!--          <el-date-picker-->
<!--            v-model="dimIntFixFrom.updateDt"-->
<!--            value-format="yyyy-MM-dd"-->
<!--            align="right"-->
<!--            type="date"-->
<!--            placeholder="选择日期"-->
<!--            :picker-options="pickerOptions">-->
<!--          </el-date-picker>-->
          <el-date-picker
            v-model="dimIntFixFrom.updateDt"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="datetime"
            placeholder="选择日期时间"
            align="right"
            :picker-options="pickerOptions">
          </el-date-picker>
        </el-form-item>

      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel('dimIntFixFrom')">取 消</el-button>
        <el-button v-if="dimIntFixDialogStatus=='create'" type="primary" @click="create('dimIntFixFrom')">确 定</el-button>
        <el-button v-else type="primary" @click="dimIntFixUpdate('dimIntFixFrom')">修 改</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="textMap[dimBusIntTranDialogStatus]" :visible.sync="dimBusIntTranDialogFormVisible" width="40%">
      <el-form :model="dimBusIntTranForm" :rules="dimBusIntTranRules" ref="dimBusIntTranForm" label-width="100px">

        <el-form-item label="积分规则编号" prop="ruleId">
          <el-input disabled class="w347" v-model="dimBusIntTranForm.ruleId"></el-input>
        </el-form-item>
        <el-form-item label="业务大类" prop="busBigtype">
          <el-input disabled class="w347" v-model="dimBusIntTranForm.busBigtype"></el-input>
        </el-form-item>
        <el-form-item label="业务小类" prop="busSmatype">
          <el-input disabled class="w347" v-model="dimBusIntTranForm.busSmatype"></el-input>
        </el-form-item>
        <el-form-item label="参数" prop="praMon">
          <el-input-number min="1" max="9999999999" class="w347" v-model.number="dimBusIntTranForm.praMon"></el-input-number>
        </el-form-item>
        <el-form-item label="积分值" prop="int">
          <el-input-number min="1" max="9999999999" class="w347" v-model.number="dimBusIntTranForm.int"></el-input-number>
        </el-form-item>
        <el-form-item label="频率" prop="freRate">
<!--          <el-input class="w347" v-model="dimBusIntTranForm.freRate"></el-input>-->
<!--          <el-select class="filter-item w347" v-model="dimBusIntTranForm.freRate" placeholder="请选择">-->
<!--            <el-option v-for="item in freRateOptions" :key="item" :label="item | freRateFilter" :value="item"> </el-option>-->
<!--          </el-select>-->
          <el-select class="filter-item w347" v-model="dimBusIntTranForm.freRate" placeholder="请选择">
            <el-option v-for="item in freRateOptions" :key="item" :label="item" :value="item"> </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input  max="50" class="w347" v-model="dimBusIntTranForm.remark"></el-input>
        </el-form-item>
        <el-form-item label="时间" prop="updateDt">
<!--          <el-input class="w347" v-model="dimBusIntTranForm.updateDt"></el-input>-->
          <el-date-picker
            v-model="dimBusIntTranForm.updateDt"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="datetime"
            placeholder="选择日期时间"
            align="right"
            :picker-options="pickerOptions">
          </el-date-picker>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel('dimBusIntTranForm')">取 消</el-button>
        <el-button v-if="dimBusIntTranDialogStatus=='create'" type="primary" @click="create('dimBusIntTranForm')">确 定</el-button>
        <el-button v-else type="primary" @click="dimBusIntTranUpdate('dimBusIntTranForm')">修 改</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="textMap[dimIntRatDialogStatus]" :visible.sync="dimIntRatDialogFormVisible" width="40%">
      <el-form :model="dimIntRatForm" :rules="dimIntRatRules" ref="dimIntRatForm" label-width="100px">

        <el-form-item label="积分" prop="int">
          <el-input-number min="1" max="99999" class="w347" v-model.number="dimIntRatForm.int"></el-input-number>
        </el-form-item>
        <el-form-item label="现金（元）" prop="cash">
          <el-input-number min="1" max="99999" class="w347" v-model.number="dimIntRatForm.cash"></el-input-number>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel('dimIntRatForm')">取 消</el-button>
        <el-button v-if="dimIntRatDialogStatus=='create'" type="primary" @click="create('dimIntRatForm')">确 定</el-button>
        <el-button v-else type="primary" @click="dimIntRatUpdate('dimIntRatForm')">修 改</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { fetchRegularRuleList, fetchRegularRuleListNew, fetchBusinessRuleList, fetchBusinessRuleListNew, fetchRatioList, putRegularRuleObj, putBusinessRuleObj, putRatioObj, getStop, getUse
  , getStopNew, getUseNew } from '@/api/integral'
import { mapGetters } from 'vuex'
export default {
  data() {
    return {
      // 定期存款积分规则表
      isDimIntFixTable: true,
      // 业务交易积分规则表
      isDimBusIntTranTable: false,
      // 积分比例表
      isDimIntRatTable: false,
      // 定期存款积分规则表历史记录
      isDimIntFixTableNew: false,
      // 业务交易积分规则表历史记录
      isDimBusIntTranTableNew: false,
      // 积分比例表历史记录
      isDimIntRatTableNew: false,
      dimIntFixTableKey: 0,
      dimBusIntTranTableKey: 1,
      dimIntRatTableKey: 2,
      listLoading: false,
      DimIntFixlist: [],
      DimBusIntTranlist: [],
      DimIntRatlist: [],
      DimIntFixlistNew: [],
      DimBusIntTranlistNew: [],
      listQuery: {
        current: 1,
        size: 10
      },
      listQueryNew: {
        current: 1,
        size: 999,
        ruleId: ''
      },
      total: 0,
      // sys_user_add: false,
      integral_update: false,
      // sys_user_delete: false,
      // sys_user_select: false,
      dimIntFixDialogFormVisible: false,
      dimBusIntTranDialogFormVisible: false,
      dimIntRatDialogFormVisible: false,
      // 定期存款积分规则修改表单
      dimIntFixFrom: {
        id: undefined,
        ruleId: undefined,
        regularGrade: undefined,
        exIntSta: undefined,
        updateDt: undefined,
        remark: undefined,
        baseMoney: undefined
      },
      // 业务交易积分规则表单
      dimBusIntTranForm: {
        id: undefined,
        ruleId: undefined,
        busBigtype: undefined,
        busSmatype: undefined,
        praMon: undefined,
        int: undefined,
        freRate: undefined,
        updateDt: undefined,
        remark: undefined
      },
      // 积分比例修改表单
      dimIntRatForm: {
        id: undefined,
        int: undefined,
        cash: undefined
      },
      dimIntFixRules: {
        exIntSta: [
          {
            required: true,
            message: '请输入兑换积分标准',
            trigger: 'blur'
          }
        ],
        updateDt: [
          {
            required: true,
            message: '请输入时间',
            trigger: 'blur'
          }
        ]
      },
      dimBusIntTranRules: {
        praMon: [
          {
            required: true,
            message: '请输入参数',
            trigger: 'blur'
          }
        ],
        freRate: [
          {
            required: true,
            message: '请选择频率',
            trigger: 'blur'
          }
        ],
        int: [
          {
            required: true,
            message: '请输入积分值',
            trigger: 'blur'
          }
        ],
        updateDt: [
          {
            required: true,
            message: '请输入时间',
            trigger: 'blur'
          }
        ]
      },
      dimIntRatRules: {
        int: [
          {
            required: true,
            message: '请输入积分',
            trigger: 'blur'
          }
        ],
        cash: [
          {
            required: true,
            message: '请输入现金',
            trigger: 'blur'
          }
        ]
      },
      textMap: {
        update: '编辑'
      },
      dimIntFixDialogStatus: '',
      dimBusIntTranDialogStatus: '',
      dimIntRatDialogStatus: '',
      freRateOptions: ['天', '月', '季度', '半年', '一年'],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now()
        },
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            picker.$emit('pick', new Date())
          }
        }, {
          text: '昨天',
          onClick(picker) {
            const date = new Date()
            date.setTime(date.getTime() - 3600 * 1000 * 24)
            picker.$emit('pick', date)
          }
        }, {
          text: '一周前',
          onClick(picker) {
            const date = new Date()
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', date)
          }
        }]
      }
    }
  },

  components: {},
  filters: {
    freRateFilter(freRate) {
      const freRateMap = {
        1: '天',
        2: '月',
        3: '季度',
        4: '半年',
        5: '一年'
      }
      return freRateMap[freRate]
    }
  },
  computed: {
    ...mapGetters(['permissions'])
  },

  mounted() {
    this.getRegularRuleList()
    // this.sys_user_add = this.permissions['/admin/user:add']
    this.integral_update = this.permissions['/intergal:update']
    // this.sys_user_delete = this.permissions['/admin/user:delete']
    // this.sys_user_select = this.permissions['/admin/user:select']
  },

  methods: {
    getList() {
      var _this = this
      if (_this.isDimIntFixTable) {
        _this.getRegularRuleList()
      } else if (_this.isDimBusIntTranTable) {
        _this.getBusinessRuleList()
      } else if (_this.isDimIntRatTable) {
        _this.getRatio()
      }
    },
    getRegularRuleList() {
      debugger
      fetchRegularRuleList(this.listQuery).then(response => {
        this.DimIntFixlist = response.data.records
        for (let i = 0; i < response.data.records.length; i++) {
          const s = response.data.records[i].beginDate
          const a = s.substring(0, 4)
          const b = s.substring(4, 6)
          const c = s.substring(6, 8)
          response.data.records[i].beginDate = a + '-' + b + '-' + c
          if (response.data.records[i].endDate !== null) {
            const s = response.data.records[i].endDate
            const a = s.substring(0, 4)
            const b = s.substring(4, 6)
            const c = s.substring(6, 8)
            response.data.records[i].endDate = a + '-' + b + '-' + c
          }
          if (response.data.records[i].endDate == null) {
            response.data.records[i].status = '生效'
          } else {
            response.data.records[i].status = '停用'
          }
        }
        this.total = response.data.total
        this.listLoading = false
      })
    },
    getBusinessRuleList() {
      fetchBusinessRuleList(this.listQuery).then(response => {
        this.DimBusIntTranlist = response.data.records
        for (let i = 0; i < response.data.records.length; i++) {
          const s = response.data.records[i].beginDate
          const a = s.substring(0, 4)
          const b = s.substring(4, 6)
          const c = s.substring(6, 8)
          response.data.records[i].beginDate = a + '-' + b + '-' + c
          if (response.data.records[i].endDate !== null) {
            const s = response.data.records[i].endDate
            const a = s.substring(0, 4)
            const b = s.substring(4, 6)
            const c = s.substring(6, 8)
            response.data.records[i].endDate = a + '-' + b + '-' + c
          }
          if (response.data.records[i].endDate == null) {
            response.data.records[i].status = '生效'
          } else {
            response.data.records[i].status = '停用'
          }
        }
        this.total = response.data.total
        this.listLoading = false
      })
    },
    getRegularRuleListNew() {
      fetchRegularRuleListNew(this.listQueryNew).then(response => {
        this.DimIntFixlistNew = response.data.records
        for (let i = 0; i < response.data.records.length; i++) {
          const s = response.data.records[i].beginDate
          const a = s.substring(0, 4)
          const b = s.substring(4, 6)
          const c = s.substring(6, 8)
          response.data.records[i].beginDate = a + '-' + b + '-' + c
          if (response.data.records[i].endDate == null) {
            response.data.records[i].status = '生效'
          } else {
            response.data.records[i].status = '停用'
          }
        }
        // this.total = response.data.total
        this.listLoading = false
      })
    },
    getBusinessRuleListNew() {
      fetchBusinessRuleListNew(this.listQueryNew).then(response => {
        this.DimBusIntTranlistNew = response.data.records
        for (let i = 0; i < response.data.records.length; i++) {
          const s = response.data.records[i].beginDate
          const a = s.substring(0, 4)
          const b = s.substring(4, 6)
          const c = s.substring(6, 8)
          response.data.records[i].beginDate = a + '-' + b + '-' + c
          if (response.data.records[i].endDate !== null) {
            const s = response.data.records[i].endDate
            const a = s.substring(0, 4)
            const b = s.substring(4, 6)
            const c = s.substring(6, 8)
            response.data.records[i].endDate = a + '-' + b + '-' + c
          }
          if (response.data.records[i].endDate == null) {
            response.data.records[i].status = '生效'
          } else {
            response.data.records[i].status = '停用'
          }
        }
        // this.total = response.data.total
        this.listLoading = false
      })
    },
    getRatio() {
      fetchRatioList(this.listQuery).then(response => {
        this.DimIntRatlist = response.data.records
        this.total = response.data.total
        this.listLoading = false
      })
    },
    handleEdit(row) {
      var _this = this
      if (_this.isDimIntFixTable) {
        _this.dimIntFixFrom.id = row.id
        _this.dimIntFixFrom.ruleId = row.ruleId
        _this.dimIntFixFrom.exIntSta = row.exIntSta
        _this.dimIntFixFrom.regularGrade = row.regularGrade
        _this.dimIntFixFrom.updateDt = row.updateDt
        _this.dimIntFixFrom.remark = row.remark
        _this.dimIntFixFrom.baseMoney = row.baseMoney
        _this.dimIntFixDialogStatus = 'update'
        _this.dimIntFixDialogFormVisible = true
      } else if (_this.isDimBusIntTranTable) {
        _this.dimBusIntTranForm.id = row.id
        _this.dimBusIntTranForm.ruleId = row.ruleId
        _this.dimBusIntTranForm.busBigtype = row.busBigtype
        _this.dimBusIntTranForm.busSmatype = row.busSmatype
        _this.dimBusIntTranForm.praMon = row.praMon
        _this.dimBusIntTranForm.int = row.int
        _this.dimBusIntTranForm.freRate = row.freRate
        _this.dimBusIntTranForm.updateDt = row.updateDt
        _this.dimBusIntTranForm.remark = row.remark
        _this.dimBusIntTranDialogStatus = 'update'
        _this.dimBusIntTranDialogFormVisible = true
      } else if (_this.isDimIntRatTable) {
        _this.dimIntRatForm.id = row.id
        _this.dimIntRatForm.int = row.int
        _this.dimIntRatForm.cash = row.cash
        _this.dimIntRatDialogStatus = 'update'
        _this.dimIntRatDialogFormVisible = true
      }
    },
    getHistory(row) {
      var _this = this
      if (_this.isDimIntFixTable) {
        this.DimIntFixlistNew = []
        _this.listQueryNew.ruleId = row.ruleId
        _this.getRegularRuleListNew()
        _this.isDimIntFixTableNew = true
      } else if (_this.isDimBusIntTranTable) {
        this.DimIntFixlistNew = []
        _this.listQueryNew.ruleId = row.ruleId
        _this.getBusinessRuleListNew()
        _this.isDimBusIntTranTableNew = true
      } else if (_this.isDimIntRatTable) {
        _this.dimIntRatForm.id = row.id
        _this.dimIntRatForm.int = row.int
        _this.dimIntRatForm.cash = row.cash
        _this.dimIntRatDialogStatus = 'update'
        _this.dimIntRatDialogFormVisible = true
      }
    },
    // 停用
    getStop(row) {
      this.$confirm(
        '此操作将停用该积分规则, 是否继续?',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).then(() => {
        getStop(row.id)
          .then(() => {
            this.getList()
            this.getRegularRuleListNew()
            this.$notify({
              title: '成功',
              message: '停用成功',
              type: 'success',
              duration: 2000
            })
          })
          .cache(() => {
            this.$notify({
              title: '失败',
              message: '停用失败',
              type: 'error',
              duration: 2000
            })
          })
      })
    },
    // 启用
    getUse(row) {
      this.$confirm(
        '此操作将启用该积分规则, 是否继续?',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).then(() => {
        getUse(row.id)
          .then(() => {
            this.getList()
            this.getRegularRuleListNew()
            this.$notify({
              title: '成功',
              message: '启用成功',
              type: 'success',
              duration: 2000
            })
          })
          .cache(() => {
            this.$notify({
              title: '失败',
              message: '启用失败',
              type: 'error',
              duration: 2000
            })
          })
      })
    },
    // 停用
    getStopNew(row) {
      this.$confirm(
        '此操作将停用该积分规则, 是否继续?',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).then(() => {
        getStopNew(row.id)
          .then(() => {
            this.getList()
            this.getBusinessRuleListNew()
            this.$notify({
              title: '成功',
              message: '停用成功',
              type: 'success',
              duration: 2000
            })
          })
          .cache(() => {
            this.$notify({
              title: '失败',
              message: '停用失败',
              type: 'error',
              duration: 2000
            })
          })
      })
    },
    // 启用
    getUseNew(row) {
      this.$confirm(
        '此操作将启用该积分规则, 是否继续?',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).then(() => {
        getUseNew(row.id)
          .then(() => {
            this.getList()
            this.getBusinessRuleListNew()
            this.$notify({
              title: '成功',
              message: '启用成功',
              type: 'success',
              duration: 2000
            })
          })
          .cache(() => {
            this.$notify({
              title: '失败',
              message: '启用失败',
              type: 'error',
              duration: 2000
            })
          })
      })
    },
    tableSwitch(val) {
      switch (val) {
        case 1:
          this.isDimIntFixTable = true
          this.isDimBusIntTranTable = false
          this.isDimIntRatTable = false
          break
        case 2:
          this.isDimIntFixTable = false
          this.isDimBusIntTranTable = true
          this.isDimIntRatTable = false
          break
        case 3:
          this.isDimIntFixTable = false
          this.isDimBusIntTranTable = false
          this.isDimIntRatTable = true
          break
        default:
          break
      }
      this.getList()
    },
    handleSizeChange(val) {
      this.listQuery.size = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listQuery.current = val
      this.getList()
    },
    cancel(formName) {
      this.disableFormVisable()
      this.$refs[formName].resetFields()
    },
    disableFormVisable() {
      this.dimIntFixDialogFormVisible = false
      this.dimBusIntTranDialogFormVisible = false
      this.dimIntRatDialogFormVisible = false
    },
    dimIntFixUpdate(formName) {
      const set = this.$refs
      set[formName].validate(valid => {
        if (valid) {
          if (this.dimIntFixFrom.remark === '') {
            this.dimIntFixFrom.remark = '  '
          }
          putRegularRuleObj(this.dimIntFixFrom).then(() => {
            this.disableFormVisable()
            this.getList()
            this.$notify({
              title: '成功',
              message: '修改成功',
              type: 'success',
              duration: 2000
            })
          })
        } else {
          return false
        }
      })
    },
    dimBusIntTranUpdate(formName) {
      const set = this.$refs
      set[formName].validate(valid => {
        if (valid) {
          if (this.dimBusIntTranForm.remark === '') {
            this.dimBusIntTranForm.remark = '  '
          }
          putBusinessRuleObj(this.dimBusIntTranForm).then(() => {
            this.disableFormVisable()
            this.getList()
            this.$notify({
              title: '成功',
              message: '修改成功',
              type: 'success',
              duration: 2000
            })
          })
        } else {
          return false
        }
      })
    },
    dimIntRatUpdate(formName) {
      const set = this.$refs
      set[formName].validate(valid => {
        if (valid) {
          putRatioObj(this.dimIntRatForm).then(() => {
            this.disableFormVisable()
            this.getList()
            this.$notify({
              title: '成功',
              message: '修改成功',
              type: 'success',
              duration: 2000
            })
          })
        } else {
          return false
        }
      })
    }
  }
}

</script>


<style lang='scss' scoped>
.w347 {
  width: 100%;
}
</style>
